import { Module } from '@nestjs/common';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { UserModule } from './user/user.module';
import { TypeOrmModule } from '@nestjs/typeorm';
import { User } from './user/entities/user.entity';
import { JwtModule } from '@nestjs/jwt';

@Module({
  imports: [
    UserModule,
    TypeOrmModule.forRoot({
      type: 'mysql',
      host: 'localhost',
      port: 3306,
      username: 'root',
      password: '123123',
      database: 'refresh_token_test',
      entities: [User],
      synchronize: true,
    }),
    JwtModule.register({
      global: true, // 这里一定要加上，全局模块，不需要其他模块引入
      secret: 'secret', // token密钥
      signOptions: { expiresIn: '30m' }, // 默认过期是时间这里设置成了30分钟
    }),
  ],
  controllers: [AppController],
  providers: [AppService],
})
export class AppModule {}
